package com.testmock;

import javax.servlet.http.HttpServletRequest;

public final class UserController {

    private final UserServiceImpl service;

    public UserController(UserServiceImpl service) {
        this.service = service;
    }

    public User saveUser(User user) {
        User save = service.save(user);
        return save;
    }

    public String returnName(){
       return getStaticName("ljw1") + " aaa";
    }

    public String httpReturnName(HttpServletRequest request){
        return httpGetStaticName("ljw1", request) + " aaa";
    }

    public static String getStaticName(String name) {
        return "A_" + name;
    }

    public static String httpGetStaticName(String name, HttpServletRequest request) {
        String aaa = request.getParameter("aaa");
        return aaa + "A_" + name;
    }

    public  String getPrivateName(String name) {

        if (publicCheck()){
            return "public 被mock 了";
        }
        if (check(name)){
            return "private 被mock 了";
        }
        return "A_" + name;
    }

    public boolean publicCheck() {
        return false;
    }

    private boolean check(String name) {
        return false;
    }

    private String say(String content) {
        return "ljw say " + content;
    }

}